<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="巡检任务路线id" prop="routeTaskId">
        <el-input
          v-model="queryParams.routeTaskId"
          placeholder="请输入巡检任务路线id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="文件名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入文件名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="编码" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地理位置id" prop="placeId">
        <el-input
          v-model="queryParams.placeId"
          placeholder="请输入地理位置id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地理位置" prop="place">
        <el-input
          v-model="queryParams.place"
          placeholder="请输入地理位置"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="详细位置" prop="placeDes">
        <el-input
          v-model="queryParams.placeDes"
          placeholder="请输入详细位置"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人id" prop="headerId">
        <el-input
          v-model="queryParams.headerId"
          placeholder="请输入负责人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人" prop="headerName">
        <el-input
          v-model="queryParams.headerName"
          placeholder="请输入负责人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="隐患类别id" prop="typeId">
        <el-input
          v-model="queryParams.typeId"
          placeholder="请输入隐患类别id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="隐患类别名称" prop="typeName">
        <el-input
          v-model="queryParams.typeName"
          placeholder="请输入隐患类别名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="隐患等级id" prop="levelId">
        <el-input
          v-model="queryParams.levelId"
          placeholder="请输入隐患等级id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="隐患等级" prop="levelName">
        <el-input
          v-model="queryParams.levelName"
          placeholder="请输入隐患等级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改单位id" prop="rectificationDeptId">
        <el-input
          v-model="queryParams.rectificationDeptId"
          placeholder="请输入整改单位id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改单位" prop="rectificationDept">
        <el-input
          v-model="queryParams.rectificationDept"
          placeholder="请输入整改单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改期限" prop="deadline">
        <el-date-picker clearable
          v-model="queryParams.deadline"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择整改期限">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="整改措施" prop="rectificationMeasure">
        <el-input
          v-model="queryParams.rectificationMeasure"
          placeholder="请输入整改措施"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改责任人id" prop="rectificationHeaderId">
        <el-input
          v-model="queryParams.rectificationHeaderId"
          placeholder="请输入整改责任人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改责任人" prop="rectificationHeaderName">
        <el-input
          v-model="queryParams.rectificationHeaderName"
          placeholder="请输入整改责任人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改日期" prop="rectificationDate">
        <el-date-picker clearable
          v-model="queryParams.rectificationDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择整改日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="所属班组id" prop="groupId">
        <el-input
          v-model="queryParams.groupId"
          placeholder="请输入所属班组id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属班组" prop="groupName">
        <el-input
          v-model="queryParams.groupName"
          placeholder="请输入所属班组"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="记录人id" prop="recordBy">
        <el-input
          v-model="queryParams.recordBy"
          placeholder="请输入记录人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="记录人" prop="recordByName">
        <el-input
          v-model="queryParams.recordByName"
          placeholder="请输入记录人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="记录时间" prop="recordAt">
        <el-date-picker clearable
          v-model="queryParams.recordAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择记录时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="创建人" prop="createByName">
        <el-input
          v-model="queryParams.createByName"
          placeholder="请输入创建人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createAt">
        <el-date-picker clearable
          v-model="queryParams.createAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="更新人" prop="updateByName">
        <el-input
          v-model="queryParams.updateByName"
          placeholder="请输入更新人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新时间" prop="updateAt">
        <el-date-picker clearable
          v-model="queryParams.updateAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择更新时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="排序" prop="sorting">
        <el-input
          v-model="queryParams.sorting"
          placeholder="请输入排序"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="版本" prop="version">
        <el-input
          v-model="queryParams.version"
          placeholder="请输入版本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="验收人id" prop="acceptanceBy">
        <el-input
          v-model="queryParams.acceptanceBy"
          placeholder="请输入验收人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="验收人" prop="acceptanceByName">
        <el-input
          v-model="queryParams.acceptanceByName"
          placeholder="请输入验收人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="验收时间" prop="acceptanceAt">
        <el-date-picker clearable
          v-model="queryParams.acceptanceAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择验收时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="验收意见" prop="acceptanceOpinion">
        <el-input
          v-model="queryParams.acceptanceOpinion"
          placeholder="请输入验收意见"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="当前执行环节id" prop="currentNodeId">
        <el-input
          v-model="queryParams.currentNodeId"
          placeholder="请输入当前执行环节id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="当前执行环节" prop="currentNode">
        <el-input
          v-model="queryParams.currentNode"
          placeholder="请输入当前执行环节"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="当前执行人id" prop="currentNodeBy">
        <el-input
          v-model="queryParams.currentNodeBy"
          placeholder="请输入当前执行人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="当前执行人" prop="currentNodeByName">
        <el-input
          v-model="queryParams.currentNodeByName"
          placeholder="请输入当前执行人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="整改超时" prop="rectificationIsOutTime">
        <el-input
          v-model="queryParams.rectificationIsOutTime"
          placeholder="请输入整改超时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dangerControl:process:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['dangerControl:process:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dangerControl:process:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dangerControl:process:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="processList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="巡检任务路线id" align="center" prop="routeTaskId" />
      <el-table-column label="文件名称" align="center" prop="name" />
      <el-table-column label="编码" align="center" prop="code" />
      <el-table-column label="地理位置id" align="center" prop="placeId" />
      <el-table-column label="地理位置" align="center" prop="place" />
      <el-table-column label="详细位置" align="center" prop="placeDes" />
      <el-table-column label="隐患内容" align="center" prop="content" />
      <el-table-column label="负责人id" align="center" prop="headerId" />
      <el-table-column label="负责人" align="center" prop="headerName" />
      <el-table-column label="隐患类别id" align="center" prop="typeId" />
      <el-table-column label="隐患类别名称" align="center" prop="typeName" />
      <el-table-column label="隐患等级id" align="center" prop="levelId" />
      <el-table-column label="隐患等级" align="center" prop="levelName" />
      <el-table-column label="整改单位id" align="center" prop="rectificationDeptId" />
      <el-table-column label="整改单位" align="center" prop="rectificationDept" />
      <el-table-column label="整改期限" align="center" prop="deadline" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deadline, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="整改措施" align="center" prop="rectificationMeasure" />
      <el-table-column label="整改责任人id" align="center" prop="rectificationHeaderId" />
      <el-table-column label="整改责任人" align="center" prop="rectificationHeaderName" />
      <el-table-column label="整改日期" align="center" prop="rectificationDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rectificationDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="整改状态，默认0" align="center" prop="rectificationStatus" />
      <el-table-column label="所属班组id" align="center" prop="groupId" />
      <el-table-column label="所属班组" align="center" prop="groupName" />
      <el-table-column label="记录人id" align="center" prop="recordBy" />
      <el-table-column label="记录人" align="center" prop="recordByName" />
      <el-table-column label="记录时间" align="center" prop="recordAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.recordAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" prop="createByName" />
      <el-table-column label="创建时间" align="center" prop="createAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新人" align="center" prop="updateByName" />
      <el-table-column label="更新时间" align="center" prop="updateAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="排序" align="center" prop="sorting" />
      <el-table-column label="备注说明" align="center" prop="remark" />
      <el-table-column label="版本" align="center" prop="version" />
      <el-table-column label="状态, 默认1(1:正常；2:冻结；98:关闭；99:删除)；" align="center" prop="status" />
      <el-table-column label="验收状态" align="center" prop="acceptanceStatus" />
      <el-table-column label="验收人id" align="center" prop="acceptanceBy" />
      <el-table-column label="验收人" align="center" prop="acceptanceByName" />
      <el-table-column label="验收时间" align="center" prop="acceptanceAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.acceptanceAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="验收意见" align="center" prop="acceptanceOpinion" />
      <el-table-column label="当前执行环节id" align="center" prop="currentNodeId" />
      <el-table-column label="当前执行环节" align="center" prop="currentNode" />
      <el-table-column label="当前执行人id" align="center" prop="currentNodeBy" />
      <el-table-column label="当前执行人" align="center" prop="currentNodeByName" />
      <el-table-column label="整改超时" align="center" prop="rectificationIsOutTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['dangerControl:process:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dangerControl:process:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改隐患-过程管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="巡检任务路线id" prop="routeTaskId">
          <el-input v-model="form.routeTaskId" placeholder="请输入巡检任务路线id" />
        </el-form-item>
        <el-form-item label="文件名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入文件名称" />
        </el-form-item>
        <el-form-item label="编码" prop="code">
          <el-input v-model="form.code" placeholder="请输入编码" />
        </el-form-item>
        <el-form-item label="地理位置id" prop="placeId">
          <el-input v-model="form.placeId" placeholder="请输入地理位置id" />
        </el-form-item>
        <el-form-item label="地理位置" prop="place">
          <el-input v-model="form.place" placeholder="请输入地理位置" />
        </el-form-item>
        <el-form-item label="详细位置" prop="placeDes">
          <el-input v-model="form.placeDes" placeholder="请输入详细位置" />
        </el-form-item>
        <el-form-item label="隐患内容">
          <editor v-model="form.content" :min-height="192"/>
        </el-form-item>
        <el-form-item label="负责人id" prop="headerId">
          <el-input v-model="form.headerId" placeholder="请输入负责人id" />
        </el-form-item>
        <el-form-item label="负责人" prop="headerName">
          <el-input v-model="form.headerName" placeholder="请输入负责人" />
        </el-form-item>
        <el-form-item label="隐患类别id" prop="typeId">
          <el-input v-model="form.typeId" placeholder="请输入隐患类别id" />
        </el-form-item>
        <el-form-item label="隐患类别名称" prop="typeName">
          <el-input v-model="form.typeName" placeholder="请输入隐患类别名称" />
        </el-form-item>
        <el-form-item label="隐患等级id" prop="levelId">
          <el-input v-model="form.levelId" placeholder="请输入隐患等级id" />
        </el-form-item>
        <el-form-item label="隐患等级" prop="levelName">
          <el-input v-model="form.levelName" placeholder="请输入隐患等级" />
        </el-form-item>
        <el-form-item label="整改单位id" prop="rectificationDeptId">
          <el-input v-model="form.rectificationDeptId" placeholder="请输入整改单位id" />
        </el-form-item>
        <el-form-item label="整改单位" prop="rectificationDept">
          <el-input v-model="form.rectificationDept" placeholder="请输入整改单位" />
        </el-form-item>
        <el-form-item label="整改期限" prop="deadline">
          <el-date-picker clearable
            v-model="form.deadline"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择整改期限">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="整改措施" prop="rectificationMeasure">
          <el-input v-model="form.rectificationMeasure" placeholder="请输入整改措施" />
        </el-form-item>
        <el-form-item label="整改责任人id" prop="rectificationHeaderId">
          <el-input v-model="form.rectificationHeaderId" placeholder="请输入整改责任人id" />
        </el-form-item>
        <el-form-item label="整改责任人" prop="rectificationHeaderName">
          <el-input v-model="form.rectificationHeaderName" placeholder="请输入整改责任人" />
        </el-form-item>
        <el-form-item label="整改日期" prop="rectificationDate">
          <el-date-picker clearable
            v-model="form.rectificationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择整改日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="所属班组id" prop="groupId">
          <el-input v-model="form.groupId" placeholder="请输入所属班组id" />
        </el-form-item>
        <el-form-item label="所属班组" prop="groupName">
          <el-input v-model="form.groupName" placeholder="请输入所属班组" />
        </el-form-item>
        <el-form-item label="记录人id" prop="recordBy">
          <el-input v-model="form.recordBy" placeholder="请输入记录人id" />
        </el-form-item>
        <el-form-item label="记录人" prop="recordByName">
          <el-input v-model="form.recordByName" placeholder="请输入记录人" />
        </el-form-item>
        <el-form-item label="记录时间" prop="recordAt">
          <el-date-picker clearable
            v-model="form.recordAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择记录时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="创建人" prop="createByName">
          <el-input v-model="form.createByName" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="创建时间" prop="createAt">
          <el-date-picker clearable
            v-model="form.createAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="更新人" prop="updateByName">
          <el-input v-model="form.updateByName" placeholder="请输入更新人" />
        </el-form-item>
        <el-form-item label="更新时间" prop="updateAt">
          <el-date-picker clearable
            v-model="form.updateAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="排序" prop="sorting">
          <el-input v-model="form.sorting" placeholder="请输入排序" />
        </el-form-item>
        <el-form-item label="备注说明" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注说明" />
        </el-form-item>
        <el-form-item label="版本" prop="version">
          <el-input v-model="form.version" placeholder="请输入版本" />
        </el-form-item>
        <el-form-item label="验收人id" prop="acceptanceBy">
          <el-input v-model="form.acceptanceBy" placeholder="请输入验收人id" />
        </el-form-item>
        <el-form-item label="验收人" prop="acceptanceByName">
          <el-input v-model="form.acceptanceByName" placeholder="请输入验收人" />
        </el-form-item>
        <el-form-item label="验收时间" prop="acceptanceAt">
          <el-date-picker clearable
            v-model="form.acceptanceAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择验收时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="验收意见" prop="acceptanceOpinion">
          <el-input v-model="form.acceptanceOpinion" placeholder="请输入验收意见" />
        </el-form-item>
        <el-form-item label="当前执行环节id" prop="currentNodeId">
          <el-input v-model="form.currentNodeId" placeholder="请输入当前执行环节id" />
        </el-form-item>
        <el-form-item label="当前执行环节" prop="currentNode">
          <el-input v-model="form.currentNode" placeholder="请输入当前执行环节" />
        </el-form-item>
        <el-form-item label="当前执行人id" prop="currentNodeBy">
          <el-input v-model="form.currentNodeBy" placeholder="请输入当前执行人id" />
        </el-form-item>
        <el-form-item label="当前执行人" prop="currentNodeByName">
          <el-input v-model="form.currentNodeByName" placeholder="请输入当前执行人" />
        </el-form-item>
        <el-form-item label="整改超时" prop="rectificationIsOutTime">
          <el-input v-model="form.rectificationIsOutTime" placeholder="请输入整改超时" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listProcess, getProcess, delProcess, addProcess, updateProcess } from "@/api/dangerControl/process";

export default {
  name: "Process",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 隐患-过程管理表格数据
      processList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        routeTaskId: null,
        name: null,
        code: null,
        placeId: null,
        place: null,
        placeDes: null,
        content: null,
        headerId: null,
        headerName: null,
        typeId: null,
        typeName: null,
        levelId: null,
        levelName: null,
        rectificationDeptId: null,
        rectificationDept: null,
        deadline: null,
        rectificationMeasure: null,
        rectificationHeaderId: null,
        rectificationHeaderName: null,
        rectificationDate: null,
        rectificationStatus: null,
        groupId: null,
        groupName: null,
        recordBy: null,
        recordByName: null,
        recordAt: null,
        createByName: null,
        createAt: null,
        updateByName: null,
        updateAt: null,
        sorting: null,
        version: null,
        status: null,
        acceptanceStatus: null,
        acceptanceBy: null,
        acceptanceByName: null,
        acceptanceAt: null,
        acceptanceOpinion: null,
        currentNodeId: null,
        currentNode: null,
        currentNodeBy: null,
        currentNodeByName: null,
        rectificationIsOutTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询隐患-过程管理列表 */
    getList() {
      this.loading = true;
      listProcess(this.queryParams).then(response => {
        this.processList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        routeTaskId: null,
        name: null,
        code: null,
        placeId: null,
        place: null,
        placeDes: null,
        content: null,
        headerId: null,
        headerName: null,
        typeId: null,
        typeName: null,
        levelId: null,
        levelName: null,
        rectificationDeptId: null,
        rectificationDept: null,
        deadline: null,
        rectificationMeasure: null,
        rectificationHeaderId: null,
        rectificationHeaderName: null,
        rectificationDate: null,
        rectificationStatus: null,
        groupId: null,
        groupName: null,
        recordBy: null,
        recordByName: null,
        recordAt: null,
        createBy: null,
        createByName: null,
        createAt: null,
        updateBy: null,
        updateByName: null,
        updateAt: null,
        sorting: null,
        remark: null,
        version: null,
        status: null,
        acceptanceStatus: null,
        acceptanceBy: null,
        acceptanceByName: null,
        acceptanceAt: null,
        acceptanceOpinion: null,
        currentNodeId: null,
        currentNode: null,
        currentNodeBy: null,
        currentNodeByName: null,
        rectificationIsOutTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加隐患-过程管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getProcess(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改隐患-过程管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateProcess(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addProcess(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除隐患-过程管理编号为"' + ids + '"的数据项？').then(function() {
        return delProcess(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dangerControl/process/export', {
        ...this.queryParams
      }, `process_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
